class Solution {
public:
    int findPoisonedDuration(vector<int>& nums, int t) {
        int n=nums.size();
        int ret=0;
        for(int i=0;i<n;i++)
        {
            if(i!=n-1&&nums[i]+t>nums[i+1])
            {
                ret+=nums[i+1]-nums[i];
            }
            else
            {
                ret+=t;
            }
        }
        return ret;
    }
};
